package ${package}.service.impl;

import org.springframework.data.domain.Page;
import ${package}.respository.${className}Repository;
import ${package}.entity.${className};
import ${package}.service.${className}Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

<#import "CopyRight.ftl" as my>
<@my.CopyRight/>
@Transactional
@Service
public class ${className}ServiceImpl implements ${className}Service {
    @Autowired
    private ${className}Repository ${className?uncap_first}Repository;

    @Override
    public Page<${className}> page(Integer pageNo,Integer pageSize)
    {
        return  ${className?uncap_first}Repository.findAll(PageUtils.of(pageNo,pageSize,Sort.by(Sort.Direction.DESC, "createTime")));
    }



    @Override
    public List<${className}> findAll() {
        return ${className?uncap_first}Repository.findAll(Sort.by(Sort.Direction.DESC,"createTime"));
    }


    @Override
    public void save(${className} bean) {
        ${className?uncap_first}Repository.save(bean);
    }

    @Override
    public void deleteByIds(Integer[] ids) {
        for (Integer id:ids) {
            ${className?uncap_first}Repository.deleteById(id);
        }
    }

    @Override
    public void update(${className} bean) {
        ${className?uncap_first}Repository.saveAndFlush(bean);
    }

    @Override
    public ${className} findById(Integer id) {
        return ${className?uncap_first}Repository.findById(id).get();
    }
}
